/*
 * @Author: your name
 * @Date: 2021-07-23 10:13:28
 * @LastEditTime: 2021-07-24 10:45:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \miniprogram-cms\js\utils.js
 */
function debounce(fn, delay, target) {
  let timer = null;
  return function (e) {
    if (timer) {
      clearTimeout(timer);
      timer = null;
    }
    timer = setTimeout(() => {
      fn.apply(target, arguments);
    }, delay);
  };
}
function throttle(fn, delay, target) {
  let canRun = true;
  return function (e) {
    if (canRun) {
      fn.apply(target, arguments);
      canRun = false;
      setTimeout(() => {
        canRun = true;
      }, delay);
    }
  };
}
